package fr.sedoo.sssdata.server.sos;

import net.opengis.ows.x11.SectionsType;
import net.opengis.sos.x10.GetCapabilitiesDocument;
import net.opengis.sos.x10.GetCapabilitiesDocument.GetCapabilities;
import fr.sedoo.sssdata.server.sos.request.SosDeleteRequest;
import fr.sedoo.sssdata.server.sos.request.SosIsPresentRequest;
import fr.sedoo.sssdata.server.sos.request.SosRequest;

public class SosRequestBuilderImpl implements SosRequestBuilder
{

	public SosRequest getGetCapabilitiesRequest() throws Exception 
	{

		SosRequest request = getDefaultSosRequest();

		GetCapabilitiesDocument doc = GetCapabilitiesDocument.Factory.newInstance();
		GetCapabilities getCapabilities = doc.addNewGetCapabilities();
		String[] versions = new String[]{"1.0.0"};
		getCapabilities.addNewAcceptVersions().setVersionArray(versions);
		SectionsType sections = getCapabilities.addNewSections();
		sections.addSection("OperationsMetadata");
		sections.addSection("ServiceIdentification");
		sections.addSection("ServiceProvider");
		sections.addSection("Filter_Capabilities");
		sections.addSection("Contents");

		getCapabilities.setService("SOS");
		request.setRequest(XmlBeansUtils.toString(doc));
		
		return request;
	}
	
	public SosRequest getInsertSensorRequest() throws Exception {
		return getDefaultSosRequest();
	}

	public SosIsPresentRequest getIsSensorPresentRequest(String sensorId) throws Exception 
	{
		return new SosIsPresentRequest(sensorId);
	}

	public SosRequest getDeleteSensorRequest(String sensorId) throws Exception {
		return new SosDeleteRequest(sensorId);
	}

	public SosRequest getAddObservationRequest() throws Exception {
		return getDefaultSosRequest();
	}

	private SosRequest getDefaultSosRequest()
	{
		return new SosRequest();
	}
	


}
